﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities;

using ERPStore.Extensions;
using CloudSoft.Workflows;

namespace ERPStore.Exporter.Workflows.Activities
{
	public sealed class GetBanishedProductList : CodeActivity
	{
		public InArgument<Providers.IExport> ExportArgument { get; set; }

		protected override void Execute(CodeActivityContext context)
		{
			var export = context.GetValue(ExportArgument);
			var exporterService = context.GetService<Services.ExporterService>();

			if (export.LeadSource != null)
			{
				var banishedProductList = exporterService.GetBanishedProductBySourceId(export.LeadSource.Id);
				export.BanishedProductIdList = banishedProductList.ToList();
			}
			else
			{
				export.BanishedProductIdList = new List<int>();
			}
		}
	}
}
